<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改抄表信息')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-waterRate-edit" th:object="${gmWaterRate}">
        <input name="ammeterId" class="form-control" type="hidden" th:field = "*{ammeterId}">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >序号：</label>
            <div class="col-sm-8">
                <input name="num" id="num" class="form-control" th:field="*{num}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >项目：</label>
            <div class="col-sm-8">
                <input name="projectName" id="projectName" class="form-control" th:field="*{projectName}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >单位：</label>
            <div class="col-sm-8">
                <input name="unitName" id="unitName" class="form-control" th:field="*{unitName}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">楼层：</label>
            <div class="col-sm-8">
                <input name="floorName" id="floorName" class="form-control" th:field="*{floorName}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >房号：</label>
            <div class="col-sm-8">
                <input name="roomNum" id="roomNum" class="form-control" th:field="*{roomNum}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >表号：</label>
            <div class="col-sm-8">
                <input name="checkMeterNum" id="checkMeterNum" class="form-control" th:field="*{checkMeterNum}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >A表上期度数：</label>
            <div class="col-sm-8">
                <input name="degreePreA" id="degreePreA" class="form-control" th:field="*{degreePreA}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >A表本期度数：</label>
            <div class="col-sm-8">
                <input name="degreeIssueA" id="degreeIssueA" class="form-control" th:field="*{degreeIssueA}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >B表上期度数：</label>
            <div class="col-sm-8">
                <input name="degreePreB" id="degreePreB" class="form-control" th:field="*{degreePreB}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >B表本期度数：</label>
            <div class="col-sm-8">
                <input name="degreeIssueB" id="degreeIssueB" class="form-control" th:field="*{degreeIssueB}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >C表上期度数：</label>
            <div class="col-sm-8">
                <input name="degreePreC" id="degreePreC" class="form-control" th:field="*{degreePreC}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >C表本期度数：</label>
            <div class="col-sm-8">
                <input name="degreeIssueC" id="degreeIssueC" class="form-control" th:field="*{degreeIssueC}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >D表上期度数：</label>
            <div class="col-sm-8">
                <input name="degreePreD" id="degreePreD" class="form-control" th:field="*{degreePreD}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >D表本期度数：</label>
            <div class="col-sm-8">
                <input name="degreeIssueD" id="degreeIssueD" class="form-control" th:field="*{degreeIssueD}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >水费月份：</label>
            <div class="col-sm-8">
                <input name="etldt" class="form-control" th:field="*{etldt}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">抄表时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input autocomplete="off" type="text" class="time-input form-control" id="issueDate" th:value="${#dates.format(gmWaterRate.issueDate, 'yyyy-MM-dd')}" placeholder="请填写日期" name="issueDate" required/>
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >乘率：</label>
            <div class="col-sm-8">
                <input name="multiplicationTerm" class="form-control" th:field="*{multiplicationTerm}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required" >单价：</label>
            <div class="col-sm-8">
                <input name="unitPrice" class="form-control" th:field="*{unitPrice}" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input name="remark" class="form-control" type="text" th:field = "*{remark}">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    var prefix = ctx + "guomao/waterRateManagement"
    var gmWaterRate = [[${gmWaterRate}]];
    $("#form-waterRate-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }
    function edit(){
        var num = $("#num").val();
        var ammeterId = $("#ammeterId").val();
        var projectName = $("#projectName").val();
        var unitName=$("#unitName").val();
        var floorName=$("#floorName").val();
        var roomNum=$("#roomNum").val();
        var checkMeterNum=$("#checkMeterNum").val();
        var degreePreA=$("#degreePreA").val();
        var degreeIssueA=$("#degreeIssueA").val();
        var degreePreB=$("#degreePreB").val();
        var degreeIssueB=$("#degreeIssueB").val();
        var degreePreC=$("#degreePreC").val();
        var degreeIssueC=$("#degreeIssueC").val();
        var degreePreD=$("#degreePreD").val();
        var degreeIssueD=$("#degreeIssueD").val();
        var issueDate=$("#issueDate").val();
        var multiplicationTerm=$("#multiplicationTerm").val();
        var unitPrice=$("#unitPrice").val();
        var remark = $("#remark").val();

        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "guomao/parkRate/edit",
            data : {
                "num":num,
                "ammeterId":ammeterId,
                "projectName":projectName,
                "unitName": unitName,
                "floorName": floorName,
                "roomNum": roomNum,
                "checkMeterNum": checkMeterNum,
                "degreePreA": degreePreA,
                "degreeIssueA": degreeIssueA,
                "degreePreB": degreePreB,
                "degreeIssueB": degreeIssueB,
                "degreePreC": degreePreC,
                "degreeIssueC": degreeIssueC,
                "degreePreD": degreePreD,
                "degreeIssueD": degreeIssueD,
                "issueDate": issueDate,
                "multiplicationTerm": multiplicationTerm,
                "unitPrice": unitPrice,
                "remark": remark
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误.");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    // function initDegreeAll(){
    //     var degreeAll = parseFloat(0);
    //     if($('#degreePreA').val()!=null&&$('#degreePreA').val()!=''){
    //         degreeAll+=parseFloat($('#degreePreA').val());
    //     }
    //     if($('#degreeIssueA').val()!=null&&$('#degreeIssueA').val()!=''){
    //         degreeAll+=parseFloat($('#degreeIssueA').val());
    //     }
    //     if($('#degreePreB').val()!=null&&$('#degreePreB').val()!=''){
    //         degreeAll+=parseFloat($('#degreeIssueB').val());
    //     }
    //     if($('#degreeIssueB').val()!=null&&$('#degreeIssueB').val()!=''){
    //         degreeAll+=parseFloat($('#degreeIssueB').val());
    //     }
    //     if($('#degreePreC').val()!=null&&$('#degreePreC').val()!=''){
    //         degreeAll+=parseFloat($('#degreeIssueB').val());
    //     }
    //     if($('#degreeIssueC').val()!=null&&$('#degreeIssueC').val()!=''){
    //         degreeAll+=parseFloat($('#degreeIssueB').val());
    //     }
    //     if($('#degreePreD').val()!=null&&$('#degreePreD').val()!=''){
    //         degreeAll+=parseFloat($('#degreeIssueB').val());
    //     }
    //     if($('#degreeIssueD').val()!=null&&$('#degreeIssueD').val()!=''){
    //         degreeAll+=parseFloat($('#degreeIssueB').val());
    //     }
    //     $('#degreePre').val(degreeAll)
    //     $('#degreeIssue').val(degreeAll)
    // }

    $("#form-waterRate-edit").validate({
        focusCleanup: true
    });
    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/editSave", $('#form-waterRate-edit').serialize());
        }
    }
    $("input[name='issueDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });



 </script>
</body>
</html>